/**
 * @author: zhiqiang
 * @version: 1.0
 * @date: 2022/3/17
 * @description:
 */
package com.lzq.state.improved;


public class TestingState implements State {
    private Context context;
    public TestingState(Context context) {
        this.context = context;
    }
    @Override
    public void test() {
        System.out.println("测试中");
        double r = Math.random();
        System.out.println(r);
        if ( r < 0.7) {
            // 转为测试失败状态
            System.out.println("测试不通过，修改后重新测试");
            context.setState(new FailState(context));
        } else {
            // 转为测试成功状态
            System.out.println("测试通过，转为测试通过状态");
            context.setState(new PassState(context));
        }
    }
}
